-- global functions

-- clones only the first 'layer' of a table
function clone(t)            -- return a copy of the table t
  local new = {}             -- create a new table
  local i, v = next(t, nil)  -- i is an index of t, v = t[i]
  while i do
    new[i] = v
    i, v = next(t, i)        -- get next index
  end
  return new
end

-- clones a table completly (subtable inclusive)
function deepclone(t)
  local new = {}             -- create a new table
  local i, v = next(t, nil)  -- i is an index of t, v = t[i]
  while i do
    if type(v) == 'table' then -- if value is table then clone it
		v = deepclone(v)
    end
    new[i] = v
    i, v = next(t, i)        -- get next index
  end
  return new
end

function compare(object1x, object1y, object1wid, object1hig, object2x, object2y, object2wid, object2hig)

			if 	object1x + object1wid > object2x and 
				object1x < object2x + object2wid and 
				object1y + object1hig > object2y and 
				object1y < object2y + object2hig
			then return true
			end
end
